package com.wing.cabinet.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 刀柜存取指令
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_command_log")
public class CommandLog  implements Serializable {


    /**
     * ID
     *
     */
//    @JsonSerialize(using=ToStringSerializer.class)
//    @TableId(type = IdType.AUTO)
    public Long id;

    /**
     * 版本号
     *
     */
    @Version
    @JsonIgnore
    protected Long version;

    /**
     * 创建时间
     */
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.Z")
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.Z")
    protected String createTime;

    /**
     * 创建者ID
     */
    private Long creator;

    /**
     * 创建者名称
     */
    private String creatorName;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonIgnore
    protected LocalDateTime updateTime;

    /**
     * 修改者
     */
    protected Long modifier;

    /**
     * 修改者名称
     */
    private String modifierName;

    /**
     * 是否已删除
     */
    protected Boolean isDeleted;

    /**
     * 备注
     */
    protected String remark;



    public enum Type implements IEnum<Integer> {

        /**
        * 发送
        */
        send(0,"发送"),
        /**
        * 收到
        */
        receive(1,"收到"),

        fail(2,"失败"),

        reconnect(3,"重连"),

        electricStatus(4,"电机"),

        remoteOpenCab(5,"远程开柜反馈"),

        print(6,"打印"),

        error(7,"异常"),

        remoteOpen(8,"远程开柜");

        private int code;
        private String desc;

        Type(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }


    /**
     * 指令类型
     */
    private Type type;

    /**
    * 指令类型描述
    */
    @TableField(exist = false)
    private String typeDesc;

    public String getTypeDesc() {
        return type == null ? null : type.getDesc();
    }

    /**
     * 柜子编号
     */
    private String cabCode;

    /**
     * 货道编号
     */
    private String spaceCode;

    /**
     * 指令内容
     */
    private String command;


    private Integer reconnectTimes;

    /**
     * 企业编码
     */
    private String enterpriseCode;

}
